package com.css.crm.dao.impl;

import java.util.List;
import org.apache.ibatis.session.SqlSession;
import com.css.crm.dao.CustomerDiscountDao;
import com.css.crm.vo.CustomerDiscountVo;

/**
 * Implementation for CustomerDiscountDao
 * 
 * @author AIS
 */
public class CustomerDiscountDaoImpl extends BaseDaoImpl implements CustomerDiscountDao {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.css.crm.dao.CustomerDiscountDao#getCustomerDiscountByCustId(java.
	 * lang.String)
	 */
	@Override
	public List<CustomerDiscountVo> getCustomerDiscountByCustId(String custId) {
		SqlSession session = getMyBatisSession();
		return session.selectList("customerDiscount.getCustomerDiscountByCustId", custId);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.css.crm.dao.CustomerDiscountDao#getDefaultCustomerDiscount(java.lang
	 * .String)
	 */
	@Override
	public CustomerDiscountVo getDefaultCustomerDiscount(String custId) {
		SqlSession session = getMyBatisSession();
		return session.selectOne("customerDiscount.getDefaultCustomerDiscount", custId);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.css.crm.dao.CustomerDiscountDao#insertCustomerDiscount(com.css.crm
	 * .vo.CustomerDiscountVo)
	 */
	@Override
	public int insertCustomerDiscount(CustomerDiscountVo customerDiscount) {
		SqlSession session = getMyBatisSession();
		return session.insert("customerDiscount.insertCustomerDiscount", customerDiscount);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.css.crm.dao.CustomerDiscountDao#updateCustomerDiscountByPK(com.css
	 * .crm.vo.CustomerDiscountVo)
	 */
	@Override
	public int updateCustomerDiscountByPK(CustomerDiscountVo customerDiscount) {
		SqlSession session = getMyBatisSession();
		return session.update("customerDiscount.updateCustomerDiscountByPK", customerDiscount);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.css.crm.dao.CustomerDiscountDao#deleteCustomerDiscountByPK(java.lang
	 * .Long)
	 */
	@Override
	public int deleteCustomerDiscountByPK(Long custDiscId) {
		SqlSession session = getMyBatisSession();
		return session.delete("customerDiscount.deleteCustomerDiscountByPK", custDiscId);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.css.crm.dao.CustomerDiscountDao#deleteCustomerDiscountByCustId(java
	 * .lang.String)
	 */
	@Override
	public int deleteCustomerDiscountByCustId(String custId) {
		SqlSession session = getMyBatisSession();
		return session.delete("customerDiscount.deleteCustomerDiscountByCustId", custId);
	}
}
